from django.http import JsonResponse


def json_response(data=None, code=0, msg="OK", **kwargs):
    """JSON 便捷响应函数"""

    if data is None:
        data = {}
    temp = {
        "code": code,
        "msg": msg,
        "data": data,
    }

    if kwargs:
        temp.update(**kwargs)

    return JsonResponse(temp)
